<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>京东密码框可见</title>
    <style>
      img {
        position: absolute;
        left: 150px;
        top: 10px;
      }
    </style>
  </head>
  <body>
    <input type="password" />
    <img src="../img/closeeye.png" alt="" />

    <script>
      const input = document.querySelector('input')
      document.querySelector('img').onclick = function () {
        if (this.src.includes('openeye')) {
          this.src = '../img/closeeye.png'
          input.type = 'password'
        } else {
          this.src = '../img/openeye.png'
          input.type = 'text'
        }
      }
    </script>
  </body>
</html>
